import { createRouter, createWebHashHistory } from 'vue-router'
import Dashboard from './components/Dashboard.vue'
import Protection from './components/Protection.vue'
import ProtectionBtc from './components/ProtectionIns/ProtectionBtc.vue'
import NftPortfolio from './components/NftPortfolio.vue'
import PolicyNfts from './components/NftPortfolios/PolicyNfts'
import CertificateNfts from './components/NftPortfolios/CertificateNfts.vue'
import Governance from './components/Governance.vue'
import MedalNfts from './components/NftPortfolios/MedalNfts.vue'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    { path: '/', redirect: '/dashboard' },
    { path: '/dashboard', name: 'DashboardIns', component: Dashboard },
    {
      path: '/protection',
      name: 'ProtectionIns',
      component: Protection,
      children: [
        {
          path: ':protectionBtc',
          name: 'protectionBtc',
          component: ProtectionBtc,
        },
      ],
    },
    { path: '/governance', name: 'governancePage', component: Governance },
    {
      path: '/nftPortfolio',
      name: 'nftPortfolio',
      component: NftPortfolio,
      children: [
        { path: '/nftPortfolio', redirect: '/nftPortfolio/policyNfts' },
        { path: 'policyNfts', name: 'policyNfts', component: PolicyNfts },
        {
          path: 'certificateNfts',
          name: 'certificateNfts',
          component: CertificateNfts,
        },
        { path: 'medalNfts', name: 'medalNfts', component: MedalNfts },
      ],
    },
  ],
})

router.beforeEach((to, from, next) => {
  document.body.scrollTop = 0
  // // firefox
  document.documentElement.scrollTop = 0
  next()
})

export default router
